import com.sun.tools.attach.AgentInitializationException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;

import java.io.IOException;

public class AppAttach {

    public static void main(String[] args) throws AttachNotSupportedException, IOException,AgentLoadException, AgentInitializationException, IOException{
        //VirtualMachine 来自tools.jar
        // VirtualMachine.attach("9444") 9444为线程PID
        VirtualMachine vm = VirtualMachine.attach("41752");
        //指定应用路径
        vm.loadAgent("D:\\d-code\\arch-trace-sniffer轨迹嗅探器\\手写trace\\arch-trace-sniffer\\test-agentmain\\target\\test-agentmain-1.0-SNAPSHOT.jar");

    }
}
